<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>历史知识查询</title>
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.0.2/css/bootstrap.min.css">
  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>

</head>
<body>
<div class="container">
    <h1 class="text-center">历史知识查询</h1>
    <div class="row mt-3">
      <div class="col-md-8 offset-md-2">
        <form id="query-form" method="POST" action="/query">
          <div class="mb-3">
            <label for="query" class="form-label">查询语句</label>
            <textarea class="form-control" id="query" name="query" rows="5"></textarea>
              <br>
          </div>
          <input type="submit" class="btn btn-primary" value="查询">
        </form>
      </div>
    </div>
    {% if result %}
    <div class="row mt-3">
      <div class="col-md-8 offset-md-2">
        <table class="table table-striped">

          <thead>
            <tr>
              <th>结果</th>
            </tr>
          </thead>

          <tbody id="query-results">
                {% if "http" in result %}
                    <th>{{prompt}}<a href="{{ result }}" target="_blank">{{ personname }}(维基百科)</a></th>

                {% elif "作品" in prompt %}
                     {% for r in result %}
                        <tr><td>{{r}}</td></tr>
                      {% endfor %}

                {% elif "字" in prompt %}
                     <th>{{prompt}}{{result}}</th>

                {% elif "所属的朝代" in prompt %}
                     <th>{{prompt}}{{result}}</th>

                {% elif "收录" in prompt %}
                    <th>{{prompt}}</th>
                    {% for r in result %}
                        <tr><td>{{r}}</td></tr>
                      {% endfor %}

                {% elif "生卒年" in prompt %}
                     <th>{{prompt}}{{personname}}生于{{born}}年，死于{{died}}年</th>

                {% else %}
                    <th>{{result}}</th>

                {% endif %}



          </tbody>
        </table>
      </div>
    </div>
     {% endif %}
  </div>
</body>
</html>


